package lab03.Test03;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test {
    public static void main(String[] args) {
        String path="D:\\test.txt";
        FileOutputStream fileOutputStream=null;
        //字节流写文件
        try {
           fileOutputStream=new FileOutputStream(path);
            //10101011字节
            fileOutputStream.write("北京欢迎你！".getBytes());
            /**
             * 读字节：
             * int tmp;
             * while((tmp=fileInputStream.read())!=-1){
             * System.out.println((char) tmp);
             * }
             */
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally{
            try {
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
